<!doctype html public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <title>Ext.util.Observable</title>
        <link rel="stylesheet" type="text/css" href="../resources/reset.css"/>
        <link rel="stylesheet" type="text/css" href="../resources/style.css" media="screen"/>
        <link rel="stylesheet" type="text/css" href="../resources/print.css" media="print">
        <!-- GC -->
    </head>
    <body>
            <div class="body-wrap">
        <div class="top-tools">
        	<img src="../resources/print.gif" width="16" height="16" align="absmiddle">&nbsp;<a href="Ext.util.Observable.html" target="_blank">Print Friendly</a><br/>

        </div>
        <h1>Class Ext.util.Observable</h1>
        <table cellspacing="0">
            <tr><td class="label">Package:</td><td>Ext.util</td></tr>
            <tr><td class="label">Class:</td><td>Observable</td></tr>
                        <tr><td class="label">Extends:</td><td>Object</td></tr>
                                    <tr><td class="label">Subclasses:</td><td><a ext:cls="Ext.BasicDialog" href="Ext.BasicDialog.html">BasicDialog</a>, <a ext:cls="Ext.BasicLayoutRegion" href="Ext.BasicLayoutRegion.html">BasicLayoutRegion</a>, <a ext:cls="Ext.Button" href="Ext.Button.html">Button</a>, <a ext:cls="Ext.Component" href="Ext.Component.html">Component</a>, <a ext:cls="Ext.ContentPanel" href="Ext.ContentPanel.html">ContentPanel</a>, <a ext:cls="Ext.LayoutManager" href="Ext.LayoutManager.html">LayoutManager</a>, <a ext:cls="Ext.Resizable" href="Ext.Resizable.html">Resizable</a>, <a ext:cls="Ext.SplitBar" href="Ext.SplitBar.html">SplitBar</a>, <a ext:cls="Ext.TabPanel" href="Ext.TabPanel.html">TabPanel</a>, <a ext:cls="Ext.TabPanelItem" href="Ext.TabPanelItem.html">TabPanelItem</a>, <a ext:cls="Ext.UpdateManager" href="Ext.UpdateManager.html">UpdateManager</a>, <a ext:cls="Ext.View" href="Ext.View.html">View</a>, <a ext:cls="Ext.data.Connection" href="Ext.data.Connection.html">Connection</a>, <a ext:cls="Ext.data.Node" href="Ext.data.Node.html">Node</a>, <a ext:cls="Ext.data.Store" href="Ext.data.Store.html">Store</a>, <a ext:cls="Ext.data.Tree" href="Ext.data.Tree.html">Tree</a>, <a ext:cls="Ext.form.BasicForm" href="Ext.form.BasicForm.html">BasicForm</a>, <a ext:cls="Ext.grid.AbstractSelectionModel" href="Ext.grid.AbstractSelectionModel.html">AbstractSelectionModel</a>, <a ext:cls="Ext.grid.ColumnModel" href="Ext.grid.ColumnModel.html">ColumnModel</a>, <a ext:cls="Ext.grid.Grid" href="Ext.grid.Grid.html">Grid</a>, <a ext:cls="Ext.grid.GridView" href="Ext.grid.GridView.html">GridView</a>, <a ext:cls="Ext.menu.Menu" href="Ext.menu.Menu.html">Menu</a>, <a ext:cls="Ext.tree.DefaultSelectionModel" href="Ext.tree.DefaultSelectionModel.html">DefaultSelectionModel</a>, <a ext:cls="Ext.tree.MultiSelectionModel" href="Ext.tree.MultiSelectionModel.html">MultiSelectionModel</a>, <a ext:cls="Ext.tree.TreeLoader" href="Ext.tree.TreeLoader.html">TreeLoader</a>, <a ext:cls="Ext.util.ClickRepeater" href="Ext.util.ClickRepeater.html">ClickRepeater</a>, <a ext:cls="Ext.util.MixedCollection" href="Ext.util.MixedCollection.html">MixedCollection</a></td></tr>
                        <tr><td class="label">Defined In:</td><td><a href="Observable.jss.html">Observable.js</a></td></tr>
        </table>
        <div class="description">
            Abstract base class that provides a common interface for publishing events. Subclasses are expected to
to have a property "events" with all the events defined.<br>
For example:
<pre><code>Employee = <b>function</b>(name){
    <b>this</b>.name = name;
    <b>this</b>.addEvents({
        <em>"fired"</em> : true,
        <em>"quit"</em> : true
    });
 }
 Ext.extend(Employee, Ext.util.Observable);</code></pre>        </div>
        <br />
        	<a href="#properties">Properties</a>
			&nbsp;&nbsp;-&nbsp;&nbsp;<a href="#methods">Methods</a>
			&nbsp;&nbsp;-&nbsp;&nbsp;<a href="#events">Events</a>
        	        <hr />
        <a name="properties"></a>
        <h2>Public Properties</h2>
        <div class="no-members">This class has no public properties.</div>        <a name="methods"></a>
        <h2>Public Methods</h2>
                <table cellspacing="0" class="member-table">
            <tr>
                <th class="sig-header" colspan="2">Method</th>
                <th class="msource-header">Defined By</th>
            </tr>
                <tr class="" expandable>
        <td class="micon" rowspan="2">&nbsp;</td>
        <td class="sig"><a class="mlink" href="#Observable.capture">Observable.capture</a>(&nbsp;<code>Observable o</code>, <code>Function fn</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span>&nbsp;) : void</td>
        <td class="msource" rowspan="2">Observable</td>
    </tr>
    <tr class="" expandable>
        <td class="mdesc">&lt;static&gt; Starts capture on the specified Observable. All events will be passed
to the supplied function with th...</td>
    </tr>
        <tr class=" alt">
        <td class="micon" rowspan="2">&nbsp;</td>
        <td class="sig"><a class="mlink" href="#Observable.releaseCapture">Observable.releaseCapture</a>(&nbsp;<code>Observable o</code>&nbsp;) : void</td>
        <td class="msource" rowspan="2">Observable</td>
    </tr>
    <tr class=" alt">
        <td class="mdesc">&lt;static&gt; Removes <b>all</b> added captures from the Observable.</td>
    </tr>
        <tr class="">
        <td class="micon" rowspan="2">&nbsp;</td>
        <td class="sig"><a class="mlink" href="#addEvents">addEvents</a>(&nbsp;<code>Object object</code>&nbsp;) : void</td>
        <td class="msource" rowspan="2">Observable</td>
    </tr>
    <tr class="">
        <td class="mdesc">Used to define events on this Observable</td>
    </tr>
        <tr class=" alt">
        <td class="micon" rowspan="2">&nbsp;</td>
        <td class="sig"><a class="mlink" href="#addListener">addListener</a>(&nbsp;<code>String eventName</code>, <code>Function handler</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span>, <span class="optional" title="Optional">[<code>Object options</code>]</span>&nbsp;) : void</td>
        <td class="msource" rowspan="2">Observable</td>
    </tr>
    <tr class=" alt">
        <td class="mdesc">Appends an event handler to this component</td>
    </tr>
        <tr class="">
        <td class="micon" rowspan="2">&nbsp;</td>
        <td class="sig"><a class="mlink" href="#fireEvent">fireEvent</a>(&nbsp;<code>String eventName</code>, <code>Object... args</code>&nbsp;) : Boolean</td>
        <td class="msource" rowspan="2">Observable</td>
    </tr>
    <tr class="">
        <td class="mdesc">Fires the specified event with the passed parameters (minus the event name).</td>
    </tr>
        <tr class=" alt">
        <td class="micon" rowspan="2">&nbsp;</td>
        <td class="sig"><a class="mlink" href="#hasListener">hasListener</a>(&nbsp;<code>String eventName</code>&nbsp;) : Boolean</td>
        <td class="msource" rowspan="2">Observable</td>
    </tr>
    <tr class=" alt">
        <td class="mdesc">Checks to see if this object has any listeners for a specified event</td>
    </tr>
        <tr class="">
        <td class="micon" rowspan="2">&nbsp;</td>
        <td class="sig"><a class="mlink" href="#on">on</a>(&nbsp;<code>String eventName</code>, <code>Function handler</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span>, <span class="optional" title="Optional">[<code>Object options</code>]</span>&nbsp;) : void</td>
        <td class="msource" rowspan="2">Observable</td>
    </tr>
    <tr class="">
        <td class="mdesc">Appends an event handler to this element (shorthand for addListener)</td>
    </tr>
        <tr class=" alt">
        <td class="micon" rowspan="2">&nbsp;</td>
        <td class="sig"><a class="mlink" href="#purgeListeners">purgeListeners</a>() : void</td>
        <td class="msource" rowspan="2">Observable</td>
    </tr>
    <tr class=" alt">
        <td class="mdesc">Removes all listeners for this object</td>
    </tr>
        <tr class="">
        <td class="micon" rowspan="2">&nbsp;</td>
        <td class="sig"><a class="mlink" href="#removeListener">removeListener</a>(&nbsp;<code>String eventName</code>, <code>Function handler</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span>&nbsp;) : void</td>
        <td class="msource" rowspan="2">Observable</td>
    </tr>
    <tr class="">
        <td class="mdesc">Removes a listener</td>
    </tr>
        <tr class=" alt">
        <td class="micon" rowspan="2">&nbsp;</td>
        <td class="sig"><a class="mlink" href="#un">un</a>(&nbsp;<code>String eventName</code>, <code>Function handler</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span>&nbsp;) : void</td>
        <td class="msource" rowspan="2">Observable</td>
    </tr>
    <tr class=" alt">
        <td class="mdesc">Removes a listener (shorthand for removeListener)</td>
    </tr>
            </table>
                <a name="events"></a>
        <h2>Public Events</h2>
        <div class="no-members">This class has no public events.</div>                
        
                    <h2 class="mdetail-head">Method Details</h2>
            <div class="detail-wrap">
                            <a name="Observable.capture"></a>
                <div class="mdetail">
                <h3>Observable.capture</i></h3>
                <code>public function Observable.capture(&nbsp;<code>Observable o</code>, <code>Function fn</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span>&nbsp;)</code>
                <div class="mdetail-desc">
                    &lt;static&gt; Starts capture on the specified Observable. All events will be passed
to the supplied function with the event name + standard signature of the event
<b>before</b> the event is fired. If the supplied function returns false,
the event will not fire.
                <div class="mdetail-params">
                    <strong>Parameters:</strong>
                    <ul><li><code>o</code> : Observable<div class="sub-desc">The Observable to capture</div></li><li><code>fn</code> : Function<div class="sub-desc">The function to call</div></li><li><code>scope</code> : Object<div class="sub-desc">(optional) The scope (this object) for the fn</div></li>                    </ul>
                    <strong>Returns:</strong>
                    <ul>
                        <li><code>void</code></li>
                    </ul>
                </div>
                </div>
                <div class="mdetail-def">This method is defined by Observable.</div>
                </div>
                            <a name="Observable.releaseCapture"></a>
                <div class="mdetail alt">
                <h3>Observable.releaseCapture</i></h3>
                <code>public function Observable.releaseCapture(&nbsp;<code>Observable o</code>&nbsp;)</code>
                <div class="mdetail-desc">
                    &lt;static&gt; Removes <b>all</b> added captures from the Observable.
                <div class="mdetail-params">
                    <strong>Parameters:</strong>
                    <ul><li><code>o</code> : Observable<div class="sub-desc">The Observable to release</div></li>                    </ul>
                    <strong>Returns:</strong>
                    <ul>
                        <li><code>void</code></li>
                    </ul>
                </div>
                </div>
                <div class="mdetail-def">This method is defined by Observable.</div>
                </div>
                            <a name="addEvents"></a>
                <div class="mdetail">
                <h3>addEvents</i></h3>
                <code>public function addEvents(&nbsp;<code>Object object</code>&nbsp;)</code>
                <div class="mdetail-desc">
                    Used to define events on this Observable
                <div class="mdetail-params">
                    <strong>Parameters:</strong>
                    <ul><li><code>object</code> : Object<div class="sub-desc">The object with the events defined</div></li>                    </ul>
                    <strong>Returns:</strong>
                    <ul>
                        <li><code>void</code></li>
                    </ul>
                </div>
                </div>
                <div class="mdetail-def">This method is defined by Observable.</div>
                </div>
                            <a name="addListener"></a>
                <div class="mdetail alt">
                <h3>addListener</i></h3>
                <code>public function addListener(&nbsp;<code>String eventName</code>, <code>Function handler</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span>, <span class="optional" title="Optional">[<code>Object options</code>]</span>&nbsp;)</code>
                <div class="mdetail-desc">
                    Appends an event handler to this component
                <div class="mdetail-params">
                    <strong>Parameters:</strong>
                    <ul><li><code>eventName</code> : String<div class="sub-desc">The type of event to listen for</div></li><li><code>handler</code> : Function<div class="sub-desc">The method the event invokes</div></li><li><code>scope</code> : Object<div class="sub-desc">(optional) The scope in which to execute the handler
function. The handler function's "this" context.</div></li><li><code>options</code> : Object<div class="sub-desc">(optional) An object containing handler configuration
properties. This may contain any of the following properties:<ul>
<li>scope {Object} The scope in which to execute the handler function. The handler function's "this" context.</li>
<li>delay {Number} The number of milliseconds to delay the invocation of the handler after te event fires.</li>
<li>single {Boolean} True to add a handler to handle just the next firing of the event, and then remove itself.</li>
<li>buffer {Number} Causes the handler to be scheduled to run in an <a ext:cls="Ext.util.DelayedTask" href="Ext.util.DelayedTask.html">Ext.util.DelayedTask</a> delayed
by the specified number of milliseconds. If the event fires again within that time, the original
handler is <em>not</em> invoked, but the new handler is scheduled in its place.</li>
</ul><br>
<p>
<b>Combining Options</b><br>
Using the options argument, it is possible to combine different types of listeners:<br>
<br>
A normalized, delayed, one-time listener that auto stops the event and passes a custom argument (forumId)
		<pre><code>el.on(<em>'click'</em>, <b>this</b>.onClick, <b>this</b>, {
 			single: true,
    		delay: 100,
    		forumId: 4
		});</code></pre>
<p>
<b>Attaching multiple handlers in 1 call</b><br>
The method also allows for a single argument to be passed which is a config object containing properties
which specify multiple handlers.
<pre><code>el.on({
			<em>'click'</em>: {
        		fn: <b>this</b>.onClick,
        		scope: <b>this</b>,
        		delay: 100
    		}, 
    		<em>'mouseover'</em>: {
        		fn: <b>this</b>.onMouseOver,
        		scope: <b>this</b>
    		},
    		<em>'mouseout'</em>: {
        		fn: <b>this</b>.onMouseOut,
        		scope: <b>this</b>
    		}
		});</code></pre>
<p>
Or a shorthand syntax which passes the same scope object to all handlers:
 	<pre><code>el.on({
			<em>'click'</em>: <b>this</b>.onClick,
    		<em>'mouseover'</em>: <b>this</b>.onMouseOver,
    		<em>'mouseout'</em>: <b>this</b>.onMouseOut,
    		scope: <b>this</b>
		});</code></pre></div></li>                    </ul>
                    <strong>Returns:</strong>
                    <ul>
                        <li><code>void</code></li>
                    </ul>
                </div>
                </div>
                <div class="mdetail-def">This method is defined by Observable.</div>
                </div>
                            <a name="fireEvent"></a>
                <div class="mdetail">
                <h3>fireEvent</i></h3>
                <code>public function fireEvent(&nbsp;<code>String eventName</code>, <code>Object... args</code>&nbsp;)</code>
                <div class="mdetail-desc">
                    Fires the specified event with the passed parameters (minus the event name).
                <div class="mdetail-params">
                    <strong>Parameters:</strong>
                    <ul><li><code>eventName</code> : String<div class="sub-desc"></div></li><li><code>args</code> : Object...<div class="sub-desc">Variable number of parameters are passed to handlers</div></li>                    </ul>
                    <strong>Returns:</strong>
                    <ul>
                        <li><code>Boolean</code><div class="sub-desc">returns false if any of the handlers return false otherwise it returns true</div></li>
                    </ul>
                </div>
                </div>
                <div class="mdetail-def">This method is defined by Observable.</div>
                </div>
                            <a name="hasListener"></a>
                <div class="mdetail alt">
                <h3>hasListener</i></h3>
                <code>public function hasListener(&nbsp;<code>String eventName</code>&nbsp;)</code>
                <div class="mdetail-desc">
                    Checks to see if this object has any listeners for a specified event
                <div class="mdetail-params">
                    <strong>Parameters:</strong>
                    <ul><li><code>eventName</code> : String<div class="sub-desc">The name of the event to check for</div></li>                    </ul>
                    <strong>Returns:</strong>
                    <ul>
                        <li><code>Boolean</code><div class="sub-desc">True if the event is being listened for, else false</div></li>
                    </ul>
                </div>
                </div>
                <div class="mdetail-def">This method is defined by Observable.</div>
                </div>
                            <a name="on"></a>
                <div class="mdetail">
                <h3>on</i></h3>
                <code>public function on(&nbsp;<code>String eventName</code>, <code>Function handler</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span>, <span class="optional" title="Optional">[<code>Object options</code>]</span>&nbsp;)</code>
                <div class="mdetail-desc">
                    Appends an event handler to this element (shorthand for addListener)
                <div class="mdetail-params">
                    <strong>Parameters:</strong>
                    <ul><li><code>eventName</code> : String<div class="sub-desc">The type of event to listen for</div></li><li><code>handler</code> : Function<div class="sub-desc">The method the event invokes</div></li><li><code>scope</code> : Object<div class="sub-desc">(optional) The scope in which to execute the handler
function. The handler function's "this" context.</div></li><li><code>options</code> : Object<div class="sub-desc">(optional)</div></li>                    </ul>
                    <strong>Returns:</strong>
                    <ul>
                        <li><code>void</code></li>
                    </ul>
                </div>
                </div>
                <div class="mdetail-def">This method is defined by Observable.</div>
                </div>
                            <a name="purgeListeners"></a>
                <div class="mdetail alt">
                <h3>purgeListeners</i></h3>
                <code>public function purgeListeners()</code>
                <div class="mdetail-desc">
                    Removes all listeners for this object
                <div class="mdetail-params">
                    <strong>Parameters:</strong>
                    <ul><li>None.</li>                    </ul>
                    <strong>Returns:</strong>
                    <ul>
                        <li><code>void</code></li>
                    </ul>
                </div>
                </div>
                <div class="mdetail-def">This method is defined by Observable.</div>
                </div>
                            <a name="removeListener"></a>
                <div class="mdetail">
                <h3>removeListener</i></h3>
                <code>public function removeListener(&nbsp;<code>String eventName</code>, <code>Function handler</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span>&nbsp;)</code>
                <div class="mdetail-desc">
                    Removes a listener
                <div class="mdetail-params">
                    <strong>Parameters:</strong>
                    <ul><li><code>eventName</code> : String<div class="sub-desc">The type of event to listen for</div></li><li><code>handler</code> : Function<div class="sub-desc">The handler to remove</div></li><li><code>scope</code> : Object<div class="sub-desc">(optional) The scope (this object) for the handler</div></li>                    </ul>
                    <strong>Returns:</strong>
                    <ul>
                        <li><code>void</code></li>
                    </ul>
                </div>
                </div>
                <div class="mdetail-def">This method is defined by Observable.</div>
                </div>
                            <a name="un"></a>
                <div class="mdetail alt">
                <h3>un</i></h3>
                <code>public function un(&nbsp;<code>String eventName</code>, <code>Function handler</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span>&nbsp;)</code>
                <div class="mdetail-desc">
                    Removes a listener (shorthand for removeListener)
                <div class="mdetail-params">
                    <strong>Parameters:</strong>
                    <ul><li><code>eventName</code> : String<div class="sub-desc">The type of event to listen for</div></li><li><code>handler</code> : Function<div class="sub-desc">The handler to remove</div></li><li><code>scope</code> : Object<div class="sub-desc">(optional) The scope (this object) for the handler</div></li>                    </ul>
                    <strong>Returns:</strong>
                    <ul>
                        <li><code>void</code></li>
                    </ul>
                </div>
                </div>
                <div class="mdetail-def">This method is defined by Observable.</div>
                </div>
                        </div>
        
                
        </div>
    <hr>
    <div style="font-size:10px;text-align:center;color:gray;">Ext - Copyright &copy; 2006-2007 Ext JS, LLC<br />All rights reserved.</div>

    </body>
</html>